{% extends 'base.html' %}
{% block title %}首页{% endblock %}
{% block content %}
    <h1>Hello, {{ user.nickname }}</h1>
    <form action="" method="post" name="post">
        {{ form.hidden_tag() }}
        <table>
            <tr>
                <td>{{ form.post.label }}</td>
                <td>{{ form.post(cols=40, rows=5, maxlength=140) }}</td>
                <td>
                    {% for error in form.post.errors %}
                        <span style="color: red">{{ error }}</span>
                    {% endfor %}
                </td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="发布"/></td>
                <td></td>
            </tr>
        </table>

    </form>
    {% for post in posts.items %}
        {% include 'post.html' %}
    {% endfor %}
    {% if posts.has_prev %}<a href="{{ url_for('index', page=posts.prev_num) }}">
        << Newer Posts</a>{% else %}<< Newer Posts{% endif %}|
    {% if posts.has_next %}<a href="{{ url_for('index', page=posts.next_num) }}">
        Older Posts >></a>{% else %}Older Posts >>{% endif %}

    {% for message in get_flashed_messages() %}
        <span style="color: red">{{ message }}</span>
    {% endfor %}

{% endblock %}